########################################################################################
@model[]
########################################################################################

########################################################################################



########################################################################################
@view[]
########################################################################################

<h1>Доска объявлений</h1>
$t[^oSensus.data.filter[
	$.select[
		*,
		( SELECT name FROM regionList WHERE id = regionId ) region, 
		( SELECT name FROM stationList WHERE id = stationId ) station, 
		( SELECT name FROM contactList WHERE id = contactId ) contact, 
		( SELECT phone FROM contactList WHERE id = contactId ) phone
	]
	$.from[residential]
]]
^if( def $t ){
	<ul>
		^t.menu{
			<li>
				^if( $t.dealTypeId == 1 ){
					^if( $t.objectTypeId == 1 ){
						<h2>Аренда / $t.rooms комнатная квартира, $t.region, м.$t.station, $t.price рублей в месяц</h2>
					}{
						<h2>Аренда / $t.rooms  ^if( $t.rooms == 1 ){комната}{комнаты}, $t.region, м.$t.station, $t.price рублей в месяц</h2>
					}					
				}{
					<h2>Продажа / $t.rooms комнатная квартира, $t.region, м.$t.station, $t.price рублей</h2>
				}
				<p>$t.description</p>
				<p>$t.contact, $t.phone</p>
			</li>
		}	
	</ul>
}

$t[^oSensus.data.filter[
	$.select[
		*,
		( SELECT name FROM objectTypeList WHERE id = objectTypeId ) objectType, 
		( SELECT name FROM regionList WHERE id = regionId ) region, 
		( SELECT name FROM stationList WHERE id = stationId ) station, 
		( SELECT name FROM contactList WHERE id = contactId ) contact, 
		( SELECT phone FROM contactList WHERE id = contactId ) phone
	]
	$.from[commercial]
]]	
^if( def $t ){
	<ul>
		^t.menu{
			<li>
				<h2>^if( $t.dealTypeId == 1 ){ Аренда }{ Продажа } / $t.objectType, $t.metricArea м.<sup>2</sup>, $t.region, м.$t.station, $t.price рублей</h2>
				<p>$t.description</p>
				<p>$t.contact, $t.phone</p>
			</li>
		}	
	</ul>
}

$t[^oSensus.data.filter[
	$.select[
		*,
		( SELECT name FROM regionList WHERE id = regionId ) region,
		( SELECT name FROM contactList WHERE id = contactId ) contact, 
		( SELECT phone FROM contactList WHERE id = contactId ) phone
	]
	$.from[land]
]]
^if( def $t ){
	<ul>
		^t.menu{
			<li>
				<h2>^if( $t.dealTypeId == 1 ){ Аренда }{ Продажа } / $t.size м.<sup>2</sup>, $t.region, $t.price рублей</h2>
				<p>$t.description</p>
				<p>$t.contact, $t.phone</p>
			</li>
		}	
	</ul>
}

$t[^oSensus.data.filter[
	$.select[
		*,
		( SELECT name FROM objectTypeList WHERE id = objectTypeId ) objectType,
		( SELECT name FROM regionList WHERE id = regionId ) region, 
		( SELECT name FROM stationList WHERE id = stationId ) station, 
		( SELECT name FROM contactList WHERE id = contactId ) contact, 
		( SELECT phone FROM contactList WHERE id = contactId ) phone
	]
	$.from[houses]
]]

^if( def $t ){
	<ul>
		^t.menu{
			<li>
				<h2>^if( $t.dealTypeId == 1 ){ Аренда }{ Продажа } / ${t.rooms}-комнатн^if($t.objectTypeId == 11){ая}{ый} $t.objectType, $t.region, м.$t.station, $t.price рублей в месяц</h2>
				<p>$t.description</p>
				<p>$t.contact, $t.phone</p>
			</li>
		}	
	</ul>
}

########################################################################################